ExtGames.MayIHangoutUtil = function(config) {
	
	ExtGames.MayIHangoutUtil.superclass.constructor.call(this, config);

};

Ext.extend(ExtGames.MayIHangoutUtil, ExtGames.HangoutUtil, {
	
	goFirst: function() {
				
		var pack = new ExtGames.Pack({
			decks: NUM_DECKS,
			jokers: 0
		});
		
		this.initialSetup(pack);
	},
	
	submitMayIRequest: function() {
		var o = {
			id: this.getMyId(),
			turn: gapi.hangout.data.getState()['turnId']
		};
		
		var delta = {};
		delta['mayi'] = JSON.stringify(o);
		gapi.hangout.data.submitDelta(delta);
	},
	
	submitMayICards: function(id, details) {
		details.id = id;
		details.sourceId = util.getMyId();
		
		gapi.hangout.data.submitDelta({
			draw: JSON.stringify(details)
		});
	},
	
	stateUpdated: function (stateEvent) {
		var adds = stateEvent.addedKeys;
		
		ExtGames.MayIHangoutUtil.superclass.stateUpdated.call(this, stateEvent);
		
		if (adds != null && adds.length > 0) {
			for (var i = 0; i < adds.length; i++) {
				
				var added = adds[i];
				
				if (added.key == 'mayi') {
					if (util.isTurn()) {
						var details = eval('('+added.value+')');
						if (details.turn == gapi.hangout.getParticipantId()) {
							game.mayIRecieved(details.id);
						}
					}
				}
			}
		}
	}
	
	
});




